package com.coded2.mobileposto.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonIgnore;


/**
 * The persistent class for the combustivel database table.
 * 
 */
@Entity
@NamedQuery(name="Combustivel.findAll", query="SELECT c FROM Combustivel c")
public class Combustivel extends com.coded2.infra.comum.ComumDTO  {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="id_combustivel")
	private int idCombustivel;

	@Column(name="no_combustivel")
	private String noCombustivel;
	
	//bi-directional many-to-one association to PostoCombustivel
	@JsonIgnore 
	@OneToMany(mappedBy="combustivel")
	private List<PostoCombustivel> postoCombustivels;
	
	@JsonIgnore 
	@Transient
	private PostoCombustivel postoCombustivel;
	
	public Combustivel() {
	}

	public int getIdCombustivel() {
		return this.idCombustivel;
	}

	public void setIdCombustivel(int idCombustivel) {
		this.idCombustivel = idCombustivel;
	}

	public String getNoCombustivel() {
		return this.noCombustivel;
	}

	public void setNoCombustivel(String noCombustivel) {
		this.noCombustivel = noCombustivel;
	}

	public List<PostoCombustivel> getPostoCombustivels() {
		return this.postoCombustivels;
	}

	public void setPostoCombustivels(List<PostoCombustivel> postoCombustivels) {
		this.postoCombustivels = postoCombustivels;
	}

	public PostoCombustivel addPostoCombustivel(PostoCombustivel postoCombustivel) {
		getPostoCombustivels().add(postoCombustivel);
		postoCombustivel.setCombustivel(this);

		return postoCombustivel;
	}

	public PostoCombustivel removePostoCombustivel(PostoCombustivel postoCombustivel) {
		getPostoCombustivels().remove(postoCombustivel);
		postoCombustivel.setCombustivel(null);

		return postoCombustivel;
	}

	@Override
	@JsonIgnore
	public Object getId() {
		
		return getIdCombustivel();
	}

}